package cn.edu.tju.elm.mapper;

import cn.edu.tju.core.model.OverdraftRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OverdraftRecordMapper extends BaseMapper<OverdraftRecord> {
    
    /**
     * 查询逾期的透支记录
     */
    @Select("SELECT * FROM t_overdraft_record WHERE status = 'ACTIVE' AND due_date < NOW()")
    List<OverdraftRecord> selectOverdueRecords();
    
    /**
     * 根据钱包ID查询活跃的透支记录
     */
    @Select("SELECT * FROM t_overdraft_record WHERE wallet_id = #{walletId} AND status = 'ACTIVE' ORDER BY created_at DESC")
    List<OverdraftRecord> selectActiveByWalletId(Long walletId);
}